import {
  ProForm,
  ProFormCascader,
  ProFormDateRangePicker,
  ProFormDigit,
  ProFormMoney,
  ProFormSelect,
  ProFormText,
  ProFormTreeSelect,
  ProFormDatePicker,
  ProFormTextArea,
  ModalForm,
  ProFormInstance,
  ProCard,
  ProTable,
  ProDescriptions,
  ProFormDependency,
} from '@ant-design/pro-components';
import ProLayout, {
  PageContainer,
  SettingDrawer,
  FooterToolbar,
} from '@ant-design/pro-layout';
import { history, useRequest } from 'umi';
import {
  EllipsisOutlined,
  PlusOutlined,
  CloudUploadOutlined,
  UploadOutlined,
  FileSearchOutlined,
} from '@ant-design/icons';
import {
  message,
  TreeSelect,
  Button,
  Card,
  Breadcrumb,
  Modal,
  Table,
  Space,
  Upload,
  UploadProps,
  Collapse,
} from 'antd';
import React, { useEffect, useRef, useState } from 'react';
import { methods } from '@/utils/request';
import moment from 'moment';
import { TitleAdapter } from '@/pages/LabAchievements/ScientificResearch/component/commons/Adapter';
const { Panel } = Collapse;
const { Item } = ProDescriptions;
export default () => {
  const [dataSource, setDataSource] = useState<any>([]);
  const [gutter, setGutter] = useState(12);
  const addPersonFrom = useRef<ProFormInstance>();
  const [proTableData, setProTableData] = useState([]);
  const [filedDisable, setFiledDisable] = useState({
    username: true,
    technicalGrade: true,
    technicalName: true,
    type: true,
  });

  const [reportId, setReportId] = useState(
    history.location.pathname.replace(
      '/LabAchievements/CooperationExchange/MeetingReport/Detail/',
      '',
    ),
  );
  const [updateStatus, setUpdateStatus] = useState(false);
  // const [formData, setFormData] = useState()
  const formRef = useRef<ProFormInstance>();

  const [modalDataSource, setModalDataSource] = useState([]); //modal的数据源
  const [selectKeys, setSelectKeys] = useState<any>(); //modal checkbox默认选中
  const [saveType, setSaveType] = useState(''); //modal 点击确认 调用新增、更新还是暂存接口
  const [isModalVisible, setIsModalVisible] = useState(false);
  const [descriptiondata, setDescriptionData] = useState<any>([]);

  const props: UploadProps = {
    name: 'file',
    action: 'http://10.1.40.84:9993/common/uploadFile',
    headers: {
      Authorization: localStorage.getItem('token') || '',
    },
    maxCount: 1,
    onChange(info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList);
      }
      if (info.file.status === 'done') {
        formRef.current?.setFieldsValue({ annexPath: info.file.response.data });

        message.success(`${info.file.name} 上传成功！`);
      } else if (info.file.status === 'error') {
        message.error(`${info.file.name} file upload failed.`);
      }
    },
  };

  //报告详细信息
  const findInvitationReportDetailById = useRequest(
    (data = null) => {
      return {
        url: 'http://10.1.40.84:9993/invitation/findInvitationReportDetailById',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        setProTableData(result.userCommonRelations);
      },
      manual: true,
    },
  );

  //更新详细信息
  const updateInvitationReport = useRequest(
    (data = null) => {
      return {
        url: 'http://10.1.40.84:9993/invitation/updateInvitationReport',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
      onSuccess: (result, params) => {
        if (result.code === 200) {
          history.push('/LabAchievements/CooperationExchange/MeetingReport');
        } else {
          message.error(result.msg);
        }
      },
      formatResult: (res) => res,
    },
  );

  //新增详细信息
  const addInvitationReport = useRequest(
    (data = null) => {
      return {
        url: 'http://10.1.40.84:9993/invitation/addInvitationReport',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
      onSuccess: (result, params) => {
        if (result.code === 200) {
          history.push('/LabAchievements/CooperationExchange/MeetingReport');
        } else {
          message.error(result.msg);
        }
      },
      formatResult: (res) => res,
    },
  );

  //下拉框
  const getLike1 = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
    },
  );
  const getLike2 = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
    },
  );
  //查找所有标签
  const getAllLabel = useRequest((data = null) => {
    return {
      url: 'http://10.1.40.84:9993/getAllLabel',
      method: 'POST',
      headers: {
        Authorization: localStorage.getItem('token') || '',
      },
      data,
    };
  });

  //根据名字查找人详细信息
  const findOneUserInfoDetailByName = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/user/findOneUserInfoDetailByName',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        console.log(result);
      },
      onError: (e, params) => {
        console.log(e);
        console.log(params);
      },
      // formatResult: res => res
      manual: true,
    },
  );
  //添加标签
  const addLabelDetail = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/addLabelDetail',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        getAllLabel.run();
        message.success('添加成功');
      },
      onError: (e, params) => {
        // console.log(e);
        // console.log(params);
      },
      // formatResult: res => res
      manual: true,
    },
  );
  const addOrUpdatePaperTemp = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/invitation/addOrUpdateInvitationReportTemp',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      onSuccess: (result, params) => {
        history.push('/LabAchievements/CooperationExchange/MeetingReport');
        console.log(result);
      },
      manual: true,
    },
  );
  //暂存

  const columns = [
    {
      title: '工号',
      dataIndex: 'username',
      key: 'username',
    },
    {
      title: '名称',
      dataIndex: 'realName',
      key: 'realName',
    },
    {
      title: '排名',
      dataIndex: 'userRank',
      key: 'userRank',
      valueType: 'digit',
    },
    {
      title: '人员类别',
      dataIndex: 'userType',
      key: 'userType',
      valueType: 'select',
      valueEnum: {
        固定人员: { text: '固定人员', status: 'Success' },
        流动人员: {
          text: '流动人员',
          status: 'Success',
        },
        学生: {
          text: '学生',
          status: 'Default',
        },
        非本室人员: {
          text: '非本室人员',
          status: 'Default',
        },
      },
    },
    {
      title: '人员身份',
      dataIndex: 'userIdentify',
      key: 'userIdentify',
      valueType: 'select',
      valueEnum: {
        第一作者: { text: '第一作者', status: 'Success' },
        通讯作者: {
          text: '通讯作者',
          status: 'Success',
        },
        其他: {
          text: '其他',
          status: 'Default',
        },
      },
    },
    {
      title: '人员职称',
      dataIndex: 'technicalName',
      key: 'technicalName',
    },
    {
      title: '职称等级',
      dataIndex: 'technicalGrade',
      key: 'technicalGrade',
      valueEnum: {
        正高级: { text: '正高级', status: 'Success' },
        副高级: {
          text: '副高级',
          status: 'Success',
        },
      },
    },
    {
      title: '完成情况',
      key: 'completeState',
      dataIndex: 'completeState',
      valueType: 'select',
      valueEnum: {
        独立完成: { text: '独立完成', status: 'Default' },
        '第一完成人(非独立完成)': {
          text: '第一完成人(非独立完成)',
          status: 'Error',
        },
        '非第一完成人(非独立完成)': {
          text: '非第一完成人(非独立完成)',
          status: 'Success',
        },
      },
    },

    {
      title: '操作',
      valueType: 'option',
      width: 200,
      hideInTable: updateStatus,
      render: (text, record: any, _, action) => [
        <a
          key="delete"
          onClick={() => {
            setDataSource(
              dataSource.filter(
                (item: any) => item.realName !== record.realName,
              ),
            );
            message.info('临时删除人员，确认人员名单后请提交！');
          }}
        >
          删除
        </a>,
      ],
    },
  ];
  //审核
  const updateStatusIpi = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/common/updateStatus',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
    },
  );

  //根据userList获取人员列表/user/getUserList
  const getUserList = useRequest(
    (data = {}) => {
      return {
        url: 'http://10.1.40.84:9993/user/getUserList',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
      onSuccess: (result) => {
        console.log(result);
        let resultTemp: any = [];
        result.map((item: any) => {
          resultTemp.push(item.webId);
        });
        console.log(resultTemp);
        setSelectKeys(resultTemp);
      },
    },
  );
  const showModal = (value: any) => {
    console.log(value);
    setModalDataSource(value);
    setIsModalVisible(true);
  };

  const handleOk = () => {
    let paramTemp: any = [];
    selectKeys.map((element: any) => {
      paramTemp.push(
        getUserList?.data.filter((item: any) => item.webId === element)[0],
      );
    });
    let formRefData: any = formRef.current?.getFieldsValue();
    // if (saveType === '暂存') {
    //   addOrUpdateSoftWareCopyRightTemp.run({
    // ...eformdata,
    // startTime:moment(time[0]).format("YYYY-MM-DD"),
    // endTime:moment(time[1]).format("YYYY-MM-DD"),
    //     userCommonRelations: paramTemp,
    //   });
    // }
    console.log(formRefData);

    const { time, ...eformdata } = formRef.current?.getFieldsValue();

    if (saveType === '新增') {
      addInvitationReport.run({
        ...eformdata,
        startTime: moment(time[0]).format('YYYY-MM-DD'),
        endTime: moment(time[1]).format('YYYY-MM-DD'),
        specialType: '大会报告',
        userCommonRelations: paramTemp,
      });
    }
    if (saveType === '更新') {
      updateInvitationReport
        .run({
          ...eformdata,
          startTime: moment(time[0]).format('YYYY-MM-DD'),
          endTime: moment(time[1]).format('YYYY-MM-DD'),
          specialType: '大会报告',
          userCommonRelations: paramTemp,
        })
        .then(() => {
          if (localStorage.getItem('isEdit') === '审核') {
            updateStatusIpi
              .run({
                tableName: 'INVITATION_REPORT',
                ids: [reportId],
                status: 2, //审核通过
                tab: '子方向视角',
              })
              .then(() => {
                history.goBack();
                message.success('操作成功');
              });
          }
        });
    }
    if (saveType === '暂存') {
      let formRefData: any = formRef.current?.getFieldsValue();
      addOrUpdatePaperTemp.run({
        ...formRefData,
        userCommonRelations: paramTemp,
        id: reportId === 'new' ? null : reportId,
        specialType: '大会报告',
      });
    }
  };

  const handleCancel = () => {
    setIsModalVisible(false);
  };

  //国家模糊查询
  const getLike = useRequest((data = { field: 'country' }) => {
    return {
      url: 'http://10.1.40.84:9993/getLike',
      method: 'POST',
      headers: {
        Authorization: localStorage.getItem('token') || '',
      },
      data,
    };
  });
  const getCity = useRequest(
    (data = { field: 'CITY', key: '' }) => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
    },
  );
  const getProvince = useRequest(
    (data = { field: 'PROVINCE', key: '' }) => {
      return {
        url: 'http://10.1.40.84:9993/getLike',
        method: 'POST',
        headers: {
          Authorization: localStorage.getItem('token') || '',
        },
        data,
      };
    },
    {
      manual: true,
    },
  );
  useEffect(() => {
    const pageTypeTemp = history.location.pathname.replace(
      '/LabAchievements/CooperationExchange/MeetingReport/Detail/',
      '',
    );
    setReportId(pageTypeTemp);
    if (pageTypeTemp != 'new') {
      findInvitationReportDetailById.run({ id: pageTypeTemp }).then((data) => {
        setDescriptionData(data);
        const { year, startTime, endTime, ...formdata } = data;
        const des = {
          year: year ? moment(year, 'YYYY') : null,
          time: [
            startTime ? moment(startTime).format('YYYY-MM-DD') : null,
            endTime ? moment(endTime).format('YYYY-MM-DD') : null,
          ],
          ...formdata,
        };
        formRef?.current?.setFieldsValue(des);
      });
    }
  }, []);

  return (
    <PageContainer
      header={{
        title:
          findInvitationReportDetailById?.data?.message &&
          findInvitationReportDetailById?.data?.isPass != 4 ? (
            <div style={{ fontSize: 18, textAlign: 'center', color: 'red' }}>
              拒绝原因：{findInvitationReportDetailById?.data?.message}
            </div>
          ) : null,
        breadcrumb: (
          <Breadcrumb>
            <Breadcrumb.Item>合作交流</Breadcrumb.Item>
            <Breadcrumb.Item>大会报告</Breadcrumb.Item>
            <Breadcrumb.Item>
              {TitleAdapter(
                reportId,
                localStorage.getItem('isEdit'),
                '大会报告',
              )}
            </Breadcrumb.Item>
          </Breadcrumb>
        ),
      }}
      extra={
        <div>
          {localStorage.getItem('isEdit') === '审核' ? (
            <Space>
              <ModalForm
                title="拒绝"
                trigger={<Button key="2">返回成员修改</Button>}
                autoFocusFirstInput
                modalProps={{
                  onCancel: () => console.log('run'),
                  destroyOnClose: true,
                }}
                submitTimeout={2000}
                onFinish={async (values) => {
                  console.log(values);
                  updateStatusIpi
                    .run({
                      tableName: 'INVITATION_REPORT',
                      ids: [reportId],
                      status: 3, //拒绝
                      message: values.message,
                      tab: '子方向视角',
                    })
                    .then(() => {
                      history.goBack();
                      message.success('操作成功');
                    });
                  return true;
                }}
                grid={true}
                initialValues={{
                  message: findInvitationReportDetailById?.data?.message,
                }}
              >
                <ProForm.Group>
                  <ProFormText
                    name="message"
                    label="拒绝原因"
                    placeholder="请输入拒绝原因"
                    colProps={{ span: 24 }}
                    rules={[{ required: true, message: '请输入拒绝原因' }]}
                  />
                </ProForm.Group>
              </ModalForm>

              <Button
                key="1"
                type="primary"
                onClick={() => {
                  let formRefData: any = formRef.current?.getFieldsValue();
                  if (!formRefData?.annexPath) {
                    message.warning('请上传材料！');
                  } else {
                    if (reportId === 'new') {
                      setSaveType('新增');
                    } else {
                      setSaveType('更新');
                    }
                    getUserList
                      .run({
                        userList: formRefData.authors.replace(/，/g, ','),
                      })
                      .then((e) => {
                        showModal(e);
                      });
                  }
                }}
              >
                提交管理员审核
              </Button>
            </Space>
          ) : null}
        </div>
      }
      content={
        <>
          {localStorage.getItem('isEdit') === '查看' ? (
            <ProCard>
              <ProDescriptions column={4} bordered labelStyle={{ width: 170 }}>
                <Item
                  label={'序号'}
                  dataIndex={'seq'}
                  span={localStorage.getItem('identity') !== '管理员' ? 0 : 4}
                >
                  {descriptiondata?.seq}
                </Item>
                <Item
                  label={'年度'}
                  dataIndex={'year'}
                  span={localStorage.getItem('identity') !== '管理员' ? 0 : 4}
                >
                  {descriptiondata?.year}
                </Item>
                <Item label={'报告人'} dataIndex={'authors'} span={4}>
                  {descriptiondata?.authors}
                </Item>
                <Item label={'报告名称'} dataIndex={'reportName'} span={2}>
                  {descriptiondata?.reportName}
                </Item>
                <Item label={'报告类型'} dataIndex={'reportType'} span={2}>
                  {descriptiondata?.reportType}
                </Item>
                <Item label={'会议名称'} dataIndex={'meetName'} span={2}>
                  {descriptiondata?.meetName}
                </Item>
                <Item label={'会议类型'} dataIndex={'meetType'}>
                  {descriptiondata?.meetType}
                </Item>
                <Item label={'会议时间'} dataIndex={'time'}>
                  {descriptiondata?.startTime && descriptiondata?.endTime
                    ? moment(descriptiondata?.startTime).format('YYYY-MM-DD') +
                      ' 到 ' +
                      moment(descriptiondata?.endTime).format('YYYY-MM-DD')
                    : null}
                </Item>

                <Item label={'佐证材料'} span={2}>
                  {descriptiondata?.annexPath ? (
                    <Button
                      type="link"
                      onClick={() => {
                        window.open(
                          findInvitationReportDetailById.data.annexPath,
                        );
                      }}
                    >
                      {' '}
                      查看材料
                    </Button>
                  ) : (
                    '暂无材料'
                  )}
                </Item>
                <Item label={'报道链接'} span={2}>
                  {descriptiondata?.reportLink ? (
                    <Button
                      type="link"
                      onClick={() => {
                        window.open(descriptiondata?.reportLink);
                      }}
                    >
                      {' '}
                      查看报道
                    </Button>
                  ) : (
                    '暂无报道'
                  )}
                </Item>
                <Item label={'国别'} dataIndex={'meetPlace'}>
                  {descriptiondata?.meetPlace}
                </Item>
                <Item label={'国家'} dataIndex={'country'}>
                  {descriptiondata?.country}
                </Item>
                {findInvitationReportDetailById?.data?.meetPlace === '国内' ? (
                  <>
                    <Item label={'省'} dataIndex={'province'} />
                    <Item label={'市'} dataIndex={'city'} />
                  </>
                ) : null}
                <Item
                  label={'标签'}
                  dataIndex={'labels'}
                  span={2}
                  request={async () => {
                    return getAllLabel.data;
                  }}
                  hideInDescriptions={
                    localStorage.getItem('identity') !== '管理员'
                  }
                >
                  {descriptiondata?.labels}
                </Item>
              </ProDescriptions>
            </ProCard>
          ) : (
            <ProForm
              grid
              layout="vertical"
              onFinish={async (values) => {
                console.log(values);
                if (!values?.annexPath) {
                  message.warning('请上传材料！');
                } else {
                  if (reportId === 'new') {
                    setSaveType('新增');
                  } else {
                    setSaveType('更新');
                  }
                  getUserList
                    .run({ userList: values.authors.replace(/，/g, ',') })
                    .then((e) => {
                      showModal(e);
                    });
                }
              }}
              autoFocusFirstInput
              formRef={formRef}
              submitter={{
                render: (props, dom) => (
                  <FooterToolbar>
                    {localStorage.getItem('isEdit') === '审核' ? null : (
                      <>
                        {reportId === 'new' ||
                        findInvitationReportDetailById?.data?.isPass + '' ===
                          '-1' ? (
                          <Button
                            onClick={() => {
                              setSaveType('暂存');
                              let values = props.form?.getFieldsValue();
                              if (values.authors) {
                                getUserList
                                  .run({ userList: values.authors })
                                  .then((e) => {
                                    showModal(e);
                                  })
                                  .catch((e) => message.error('作者填写有误'));
                              } else {
                                addOrUpdatePaperTemp.run({
                                  ...values,
                                  userCommonRelations: proTableData,
                                  id: reportId === 'new' ? null : reportId,
                                  specialType: '大会报告',
                                });
                              }
                            }}
                          >
                            暂存
                          </Button>
                        ) : null}
                        <Button
                          type="primary"
                          onClick={() => {
                            // console.log("?");
                            formRef.current?.submit();
                          }}
                        >
                          提交
                        </Button>
                        {/* {dom} */}
                      </>
                    )}
                  </FooterToolbar>
                ),
              }}
            >
              <ProFormDigit label="编号" name={'id'} hidden />
              <ProFormDigit name={'isPass'} hidden />
              <ProFormText name="annexPath" hidden />
              <ProForm.Group title={'基本信息'}>
                <ProFormDigit
                  label="序号"
                  name={'seq'}
                  colProps={{ span: 4 }}
                  hidden={true}
                  disabled
                />
                <ProFormText
                  label="报告名称"
                  name={'reportName'}
                  colProps={{
                    span: 6,
                  }}
                  rules={[{ required: true, message: '请输入' }]}
                />
                <ProFormText
                  label="报告人（作者信息中本人姓名为英文的请改成中文）"
                  name={'authors'}
                  colProps={{ span: 6 }}
                  rules={[{ required: true, message: '请输入' }]}
                  placeholder="添加人员信息，以英文逗号分隔"
                />
                <ProFormSelect
                  label="报告类型"
                  name={'reportType'}
                  colProps={{ span: 3 }}
                  options={[
                    { label: '大会报告', value: '大会报告' },
                    { label: '分会场报告', value: '分会场报告' },
                    { label: '其他', value: '其他' },
                  ]}
                  rules={[{ required: true, message: '请选择' }]}
                />
              </ProForm.Group>
              <ProForm.Group title="详细内容">
                <ProFormText
                  label="会议名称"
                  name={'meetName'}
                  colProps={{ span: 5 }}
                  rules={[{ required: true, message: '请输入' }]}
                />
                <ProFormSelect
                  name="meetType"
                  label="会议类型"
                  colProps={{ span: 5 }}
                  options={[
                    { label: '全球性', value: '全球性' },
                    { label: '区域性', value: '区域性' },
                    { label: '双边性', value: '双边性' },
                    { label: '全国性', value: '全国性' },
                    { label: '其他', value: '其他' },
                  ]}
                  rules={[{ required: true, message: '请选择' }]}
                />
                <ProFormDateRangePicker
                  name="time"
                  label="会议时间"
                  colProps={{ span: 5 }}
                  rules={[{ required: true, message: '请选择' }]}
                />
              </ProForm.Group>
              <ProForm.Group>
                <ProFormDatePicker.Year
                  name="year"
                  label="年度"
                  colProps={{ span: 3 }}
                  hidden={localStorage.getItem('identity') !== '管理员'}
                />

                <ProFormSelect
                  name="meetPlace"
                  label="国别（会议地点）"
                  options={[
                    { label: '国内', value: '国内' },
                    { label: '国外', value: '国外' },
                  ]}
                  fieldProps={{
                    onChange: (e) => {
                      formRef.current?.setFieldsValue({ country: null });
                      getLike.run({ field: 'country', level: e });
                    },
                  }}
                  colProps={{ span: 3 }}
                  rules={[{ required: true, message: '请选择' }]}
                />

                <ProFormDependency name={['meetPlace']}>
                  {({ meetPlace }) => {
                    return (
                      <>
                        <ProFormSelect.SearchSelect
                          name="country"
                          label="国家（会议地点）"
                          mode="single"
                          fieldProps={{
                            labelInValue: false,
                            onChange: (e: any) => {
                              //改变国家时清空省市
                              formRef.current?.setFieldsValue({
                                province: null,
                                city: null,
                              });
                              if (e === '中国') {
                                getProvince.run({
                                  field: 'PROVINCE',
                                  key: '',
                                });
                              }
                            },
                          }}
                          rules={[
                            {
                              required: meetPlace === '国外',
                              message: '请输入会议地点',
                            },
                          ]}
                          options={getLike.data}
                          colProps={{ span: 3 }}
                        />
                        <ProFormSelect.SearchSelect
                          mode="single"
                          fieldProps={{
                            labelInValue: false,
                            onChange: (e: any) => {
                              console.log(e);
                              //改变省时清空市
                              formRef.current?.setFieldsValue({
                                city: null,
                              });
                              getCity.run({
                                field: 'CITY',
                                level: e,
                                key: '',
                              });
                            },
                            options: getProvince?.data,
                          }}
                          name="province"
                          label="省"
                          colProps={{ span: 3 }}
                          rules={[
                            {
                              required: meetPlace === '国内',
                              message: '请输入省份',
                            },
                          ]}
                          disabled={meetPlace != '国内'}
                        />
                        <ProFormSelect.SearchSelect
                          mode="single"
                          fieldProps={{ labelInValue: false }}
                          options={getCity.data}
                          name="city"
                          label="市"
                          colProps={{ span: 3 }}
                          rules={[
                            {
                              required: meetPlace === '国内',
                              message: '请输入城市',
                            },
                          ]}
                          disabled={meetPlace != '国内'}
                        />
                      </>
                    );
                  }}
                </ProFormDependency>
              </ProForm.Group>
              <ProForm.Group title="佐证材料">
                <ProFormText
                  colProps={{
                    span: 6,
                  }}
                  name="reportLink"
                  label="报道链接"
                />
                <ProFormSelect.SearchSelect
                  name="labels"
                  label="大会报告标签"
                  options={getAllLabel?.data}
                  fieldProps={{ labelInValue: false }}
                  colProps={{ span: 8 }}
                  hidden={localStorage.getItem('identity') !== '管理员'}
                  addonAfter={
                    <ModalForm<{
                      year: string;
                      labelName: string;
                    }>
                      title="新增标签"
                      trigger={<a>新增标签</a>}
                      autoFocusFirstInput
                      modalProps={{
                        onCancel: () => console.log('run'),
                      }}
                      submitTimeout={2000}
                      onFinish={async (values) => {
                        addLabelDetail.run(values);
                        return true;
                      }}
                    >
                      <ProForm.Group>
                        <ProFormDatePicker.Year
                          width="md"
                          name="year"
                          label="标签年份"
                          required
                        />
                        <ProFormText
                          width="md"
                          name="labelName"
                          label="标签名称"
                          required
                        />
                      </ProForm.Group>
                    </ModalForm>
                  }
                />
              </ProForm.Group>
              <Upload {...props}>
                <Button
                  icon={<UploadOutlined />}
                  type="link"
                  onClick={() =>
                    message.info(
                      '请选择.docx、.doc、.pdf、.xls格式的文件上传！！',
                    )
                  }
                >
                  上传材料（上传会议照片，以会议名称命名）
                </Button>
              </Upload>

              {formRef?.current?.getFieldValue('annexPath') ? (
                <Button
                  type="link"
                  onClick={() => {
                    window.open(formRef?.current?.getFieldValue('annexPath'));
                  }}
                  icon={<FileSearchOutlined />}
                >
                  {' '}
                  查看材料
                </Button>
              ) : (
                <Button type="link"> 暂无材料</Button>
              )}
            </ProForm>
          )}
        </>
      }
    >
      <Modal
        title="请确认人员！"
        visible={isModalVisible}
        onOk={handleOk}
        onCancel={handleCancel}
        forceRender
      >
        <Table
          size="small"
          pagination={{ hideOnSinglePage: true, pageSize: 10 }}
          rowKey={'webId'}
          rowSelection={{
            onChange: (selectedRowKeys: React.Key[]) => {
              setSelectKeys(selectedRowKeys);
            },
            selectedRowKeys: selectKeys,
          }}
          columns={[
            {
              title: '工号',
              dataIndex: 'username',
              key: 'username',
            },
            {
              title: '姓名',
              dataIndex: 'realName',
              key: 'realName',
            },
            {
              title: '人员类型',
              dataIndex: 'userType',
              key: 'userType',
            },
          ]}
          dataSource={modalDataSource}
        />
      </Modal>
    </PageContainer>
  );
};
